﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Web;
using System.Web.Configuration;

namespace PeonyShop.DAL
{
    public class BaseDA
    {
        protected static SqlDatabase _conn;
        public static SqlDatabase DB 
        {
            get 
            {
                if (_conn == null)
                {
                    if (HttpContext.Current.Application["DBMain"] == null)
                    {
                        HttpContext.Current.Application["DBMain"] = WebConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                    }
                    _conn = new SqlDatabase(HttpContext.Current.Application["DBMain"].ToString());
                }
                return _conn;
            }
        }
    }
}
